package utils 
{
	import core.Vector2D;
	/**
	 * ...
	 * @author Kylin206
	 */
	public class MathUtil 
	{
		
		/**
		 * 两点间距离是否等于指定值
		 * @param	p1
		 * @param	p2
		 * @param	val
		 * @return
		 */
		static public function dis_eq(p1:Vector2D, p2:Vector2D, val:Number):Boolean 
		{
			if (Math.abs(p1.distX(p2)) > val || Math.abs(p1.distY(p2)) > val)
			{
				return false;
			}
			
			return p1.distSQ(p2) == val * val;
		}
		
		
		/**
		 * 两点间距离是否小于（等于）指定值
		 * @param	p1
		 * @param	p2
		 * @param	val
		 * @param	or_eq
		 * @return
		 */
		static public function dis_lt(p1:Vector2D, p2:Vector2D, val:Number, or_eq:Boolean = true):Boolean 
		{
			if (Math.abs(p1.distX(p2)) > val || Math.abs(p1.distY(p2)) > val)
			{
				return false;
			}
			
			if (or_eq)
			{
				return p1.distSQ(p2) <= val * val;
			}
			else
			{
				return p1.distSQ(p2) < val * val;
			}
		}
		
		/**
		 * 两点间距离是否大于（等于）指定值
		 * @param	p1
		 * @param	p2
		 * @param	val
		 * @param	or_eq
		 * @return
		 */
		static public function dis_gt(p1:Vector2D, p2:Vector2D, val:Number, or_eq:Boolean = true):Boolean 
		{
			if (or_eq)
			{
				return p1.distSQ(p2) >= val * val;
			}
			else
			{
				return p1.distSQ(p2) > val * val;
			}
		}
		
	}

}